package Day1;

import java.util.Random;
import java.util.Scanner;

public class MagicNubser {
    public static void main(String[] args) {
        Random random = new Random();
        int guessnum = random.nextInt(2) ;
        int flag,jihui=0;
        for ( flag = 0; flag <5; flag++) {
            System.out.println("0:石头，1：剪刀，2:布" + "输入你要出的数");
            Scanner scanner = new Scanner(System.in);
            int oneself = scanner.nextInt();
            if (guessnum == oneself) {
                System.out.println("这局平局");
            } else if (guessnum - oneself == 2) {
                System.out.println("这局你输了");
            } else if ((guessnum - oneself == 1) || (guessnum - oneself == -2)) {
                System.out.println("这局你赢了");
                jihui++;
            } else if (guessnum - oneself == -1) {
                System.out.println("这局你输了");
            }
            if (jihui == 3) {
                System.out.println("你赢了最终的胜利");
                break;
            }

            if (flag<4) {
                System.out.println("你还剩" + (5 - flag-1) + "次机会");

            } else {
                System.out.println("你的机会用完了！");
            }
        }
    }
}
